package com.zzyl.nursing.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zzyl.common.annotation.Log;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.enums.BusinessType;
import com.zzyl.nursing.domain.Commenter;
import com.zzyl.nursing.service.ICommenterService;
import com.zzyl.common.utils.poi.ExcelUtil;
import com.zzyl.common.core.page.TableDataInfo;

/**
 * 用户评价Controller
 * 
 * @author ruoyi
 * @date 2025-06-24
 */
@RestController
@RequestMapping("/nursing/commenter")
public class CommenterController extends BaseController
{
    @Autowired
    private ICommenterService commenterService;

    /**
     * 查询用户评价列表
     */
    @PreAuthorize("@ss.hasPermi('nursing:commenter:list')")
    @GetMapping("/list")
    public TableDataInfo list(Commenter commenter)
    {
        startPage();
        List<Commenter> list = commenterService.selectCommenterList(commenter);
        return getDataTable(list);
    }

    /**
     * 导出用户评价列表
     */
    @PreAuthorize("@ss.hasPermi('nursing:commenter:export')")
    @Log(title = "用户评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Commenter commenter)
    {
        List<Commenter> list = commenterService.selectCommenterList(commenter);
        ExcelUtil<Commenter> util = new ExcelUtil<Commenter>(Commenter.class);
        util.exportExcel(response, list, "用户评价数据");
    }

    /**
     * 获取用户评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('nursing:commenter:query')")
    @GetMapping(value = "/{cId}")
    public AjaxResult getInfo(@PathVariable("cId") Integer cId)
    {
        return success(commenterService.selectCommenterByCId(cId));
    }

    /**
     * 新增用户评价
     */
    @PreAuthorize("@ss.hasPermi('nursing:commenter:add')")
    @Log(title = "用户评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Commenter commenter)
    {
        return toAjax(commenterService.insertCommenter(commenter));
    }

    /**
     * 修改用户评价
     */
    @PreAuthorize("@ss.hasPermi('nursing:commenter:edit')")
    @Log(title = "用户评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Commenter commenter)
    {
        return toAjax(commenterService.updateCommenter(commenter));
    }

    /**
     * 删除用户评价
     */
    @PreAuthorize("@ss.hasPermi('nursing:commenter:remove')")
    @Log(title = "用户评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cIds}")
    public AjaxResult remove(@PathVariable Integer[] cIds)
    {
        return toAjax(commenterService.deleteCommenterByCIds(cIds));
    }
}
